Skip to content

fix(tests): anchor calendar tests to past dates to avoid user-status side effects#426

Merged
bigcat88 merged 1 commit into
mainfrom
fix/calendar-test-past-dates
Apr 18, 2026
Merged

fix(tests): anchor calendar tests to past dates to avoid user-status side effects#426
bigcat88 merged 1 commit into
mainfrom
fix/calendar-test-past-dates

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented Apr 18, 2026

Calendar tests create events anchored to now. Nextcloud's user-status app auto-sets a 📅 In a meeting icon for admin when any event overlaps the next 5 minutes, and caches that for 5 min. user_status_test.py::test_get_status_async[app_async-1 2 3] runs shortly after and breaks on assert status_icon is None.

Moved the three offending events ~400 days back. CRUD semantics unchanged, side-effect gone.

Summary by CodeRabbit

  • Tests
    • Updated calendar tests to anchor events to a fixed historic baseline (400 days in the past), revised lifecycle and date-range scenarios, and refreshed expected event summaries so searches reliably include or exclude intended items across environments.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

Tests in tests/actual_tests/calendar_test.py were updated to anchor event datetimes 400 days in the past and to adjust SUMMARY values and date-range search assertions accordingly.

Changes

Cohort / File(s) Summary
Test Data Updates
tests/actual_tests/calendar_test.py
Replaced runtime datetime.now() anchors with a fixed now - 400 days anchor, updated dtstart/dtend values for created events, changed SUMMARY strings (e.g., "Day 0/Day +1/Day +7 Event"), and adjusted expected presence/absence in date-range search assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: calendar tests are anchored to past dates to prevent Nextcloud's status service from detecting overlapping events.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/calendar-test-past-dates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/actual_tests/calendar_test.py (1)

89-97: 🧹 Nitpick | 🔵 Trivial

Rename now — it's 400 days in the past.

Minor readability nit: the variable name now actively misleads readers of the lifecycle block, since every dtstart=now is in fact ~13 months ago. A name like past (matching test_create_delete) or anchor keeps the fix intent visible.

♻️ Proposed rename
-        # Use a past anchor so these events don't trigger Nextcloud's
-        # calendar-status automation (see test_create_delete for details).
-        now = datetime.datetime.now() - datetime.timedelta(days=400)
-        calendar.save_event(
-            dtstart=now,
-            dtend=now + datetime.timedelta(hours=2),
+        # Use a past anchor so these events don't trigger Nextcloud's
+        # calendar-status automation (see test_create_delete for details).
+        past = datetime.datetime.now() - datetime.timedelta(days=400)
+        calendar.save_event(
+            dtstart=past,
+            dtend=past + datetime.timedelta(hours=2),
             summary="Original Title",
         )
@@
         calendar.save_event(
-            dtstart=now,
-            dtend=now + datetime.timedelta(hours=1),
+            dtstart=past,
+            dtend=past + datetime.timedelta(hours=1),
             summary="Event with spëcial chars: <>&\"'",
         )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/actual_tests/calendar_test.py` around lines 89 - 97, The variable now
is misleading because it represents a timestamp 400 days in the past; rename it
to a clearer identifier (e.g., past or anchor) wherever it is declared and used
in this test block so the intent is obvious—update the assignment and all usages
passed to calendar.save_event (dtstart, dtend) and any other references in the
test lifecycle; ensure the new name matches the existing rename in
test_create_delete for consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/actual_tests/calendar_test.py`:
- Around line 89-97: The variable now is misleading because it represents a
timestamp 400 days in the past; rename it to a clearer identifier (e.g., past or
anchor) wherever it is declared and used in this test block so the intent is
obvious—update the assignment and all usages passed to calendar.save_event
(dtstart, dtend) and any other references in the test lifecycle; ensure the new
name matches the existing rename in test_create_delete for consistency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4542217f-21b3-4e72-992c-70d359b87102

📥 Commits

Reviewing files that changed from the base of the PR and between 0caa451 and 0da343d.

📒 Files selected for processing (1)
  • tests/actual_tests/calendar_test.py

@oleksandr-nc oleksandr-nc force-pushed the fix/calendar-test-past-dates branch from 0da343d to adc82a2 Compare April 18, 2026 17:24
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/actual_tests/calendar_test.py (1)

135-177: 🧹 Nitpick | 🔵 Trivial

LGTM — search windows shifted coherently with base.

All start/end bounds are expressed relative to base, so anchoring in the past doesn't affect the REPORT logic under test. Renamed Day 0/+1/+7 summaries are unambiguous and the inclusion/exclusion assertions line up with each window.

Optional nit: per the tests/** guideline on adequate assertion messages, consider adding messages to the in/not in checks (e.g. assert "Day +7 Event" not in summaries, f"unexpected: {summaries}") to make CI failures self-diagnosing — but this matches existing style in the file, so feel free to skip.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/actual_tests/calendar_test.py` around lines 135 - 177, Tests currently
assert membership with bare assert "X" in summaries / not in summaries which can
yield unclear failures; update the three membership assertions around the
calendar.search calls (referencing the variable base and the
calendar.search/results handling) to include informative assertion messages
(e.g., append , f"unexpected summaries: {summaries}") so CI failures show the
actual summaries contents while keeping the same assertions and semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/actual_tests/calendar_test.py`:
- Around line 135-177: Tests currently assert membership with bare assert "X" in
summaries / not in summaries which can yield unclear failures; update the three
membership assertions around the calendar.search calls (referencing the variable
base and the calendar.search/results handling) to include informative assertion
messages (e.g., append , f"unexpected summaries: {summaries}") so CI failures
show the actual summaries contents while keeping the same assertions and
semantics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2f36b199-f0b0-4167-b375-9e08f8c0cd25

📥 Commits

Reviewing files that changed from the base of the PR and between 0da343d and adc82a2.

📒 Files selected for processing (1)
  • tests/actual_tests/calendar_test.py

@bigcat88 bigcat88 force-pushed the fix/calendar-test-past-dates branch from adc82a2 to b6cbd15 Compare April 18, 2026 17:25
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/actual_tests/calendar_test.py (1)

158-158: 🧹 Nitpick | 🔵 Trivial

Update the stale “today” comment.

Line 158 still refers to “today”, but the test is now intentionally anchored to Day 0.

Proposed comment fix
-        # Search for today only
+        # Search for day 0 only
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/actual_tests/calendar_test.py` at line 158, Replace the stale inline
comment "# Search for today only" with a comment that correctly reflects the
test's anchor to Day 0 (for example "# Search for Day 0 only") so the comment
matches the test's intent; update the comment near the calendar test where the
original string "# Search for today only" appears.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@tests/actual_tests/calendar_test.py`:
- Line 158: Replace the stale inline comment "# Search for today only" with a
comment that correctly reflects the test's anchor to Day 0 (for example "#
Search for Day 0 only") so the comment matches the test's intent; update the
comment near the calendar test where the original string "# Search for today
only" appears.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 22a371ef-5123-4dcf-9b88-0a63ed01ba35

📥 Commits

Reviewing files that changed from the base of the PR and between adc82a2 and b6cbd15.

📒 Files selected for processing (1)
  • tests/actual_tests/calendar_test.py

@bigcat88 bigcat88 merged commit c834931 into main Apr 18, 2026
15 checks passed
@bigcat88 bigcat88 deleted the fix/calendar-test-past-dates branch April 18, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant